package com.hq.service.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.hq.dao.ConverMapper; 
import com.hq.pojo.Conver;
import com.hq.service.ConverService;
import com.hq.utils.MyBatisUtil;

public class ConverImpl implements ConverService {

	@Override
	public int insertConver(Conver conver) {
		SqlSession session = null;
		try {
			session = MyBatisUtil.getSqlSession(true);
			ConverMapper converMapper = session.getMapper(ConverMapper.class);
			int i  = converMapper.insertConver(conver);
			return i;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyBatisUtil.closeSqlSession(session);
		}
		return 0;
	}

	@Override
	public Conver getOneConver() {
		SqlSession session = null;
		try {
			session = MyBatisUtil.getSqlSession(true);
			ConverMapper converMapper = session.getMapper(ConverMapper.class);
			return converMapper.getOneConver();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyBatisUtil.closeSqlSession(session);
		}
		return null;
	}

	@Override
	public List<Conver> pushMoreConver(int skip, int count,Integer conver_id) {
		SqlSession session = null;
		try {
			session = MyBatisUtil.getSqlSession(true);
			ConverMapper converMapper = session.getMapper(ConverMapper.class);
			return converMapper.getMoreConver(skip, count,conver_id);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyBatisUtil.closeSqlSession(session);
		}
		return null;
	}

}
